package net.wanho.shop.controller;

import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import net.wanho.shop.service.FileService;
import net.wanho.shop.vo.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
@Api("文件上传接口")
@RequiredArgsConstructor
public class FileController {

    private final FileService fileService;

    @PostMapping("/upload")
    public AjaxResult upload(MultipartFile file) {
        String url = fileService.upload(file);
        return AjaxResult.success("上传成功", url);
    }

}